function login(){
    let role = $('input[name="role"]:checked').val();
    let uid = $('#uid').val();
    let upwd = $('#upwd').val();
    let data = {
        role: role,
        uid: uid,
        upwd: upwd
    }
    // console.log(data);
    $.ajax({
        method: 'POST',
        data: data,
        url: './doLogin.php',
        success: function(res){
            if (res.status == 1){
                alert(`您好，${res.uname}!`)
                window.location.pathname = '/TeacherStuSys/index.php'
            }else if(res.status == 0){
                alert('用户名或密码错误！')
            }
        }
    })
}


$('#login-btn').on('click', login)
$('#upwd').on('keydown', function(event){
    if (event.keyCode == 13) login()
})
